home *** CD-ROM | disk | FTP | other *** search
- Path: telepost.no!usenet
- From: Carsten Arnholm <ca@sesam.dnv.no>
- Newsgroups: comp.lang.c++,comp.lang.fortran
- Subject: Re: Calling Fortran in C++
- Date: 11 Jan 1996 13:59:19 GMT
- Organization: DNV
- Message-ID: <4d353n$sk1@nms.telepost.no>
- References: <4cr87l$794$1@mhafc.production.compuserve.com> <4crisr$v3u@odin.sunquest.com> <4ctro6$28n@nms.telepost.no> <o9thgy5krp7.fsf@aqua2.marina.unit.no>
- NNTP-Posting-Host: hugin.sesam.dnv.no
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1 (Windows; I; 32bit)
-
- jenhel@stud.unit.no (Jens Helmers) wrote:
- >Do MS VC++/Powerstation handle arguments of general user defined
- >F90-types with or without storage association?
- >What about F90 pointers?
- >
- >
- >TYPE a
- > .......
- >END TYPE a
- >
- >
- >TYPE b
- > SEQUENCE
- > .......
- >END TYPE b
- >
- >
- >Jens Helmers,
- >jenhel@marin.unit.no
-
-
- I do not have any practical experience with F90, only F77 so
- I don't know the answer to this (interesting) question.
-
- In my F90 book (Fortran 90 Explained, by Metcalf & Reid), the
- SEQUENCE attribute is listed as "Deprecated". I guess this means
- you should be carful in using it (is there a more standard way?).
-
- I guess the F90 TYPE is a close match to the C/C++ struct.
- In fortran 77 there is only one type that has some resemblance
- with C/C++ structs, namely the CHARACTER type (it has a "char*"
- pointer and a length). It is the CHARACTER type which has a
- tendency to cause problems when you want to port mixed language
- programs to new platforms.
-
- My hope would be that you could declare a class/struct in C++
- with the same memory layout as the F90 user defined type. Perhaps
- you need something like the SEQUENCE attribute to control the
- memory layout of the F90 type.
-
- If you could do that, I guess you could pass C/C++ structs
- as a "call by reference" parameter, and receive it as a F90 user
- defined type in FORTRAN. Whether the different F90 compilers have
- the same idea about passing such parameters, I don't know.
- Maybe some compilers would require a "call by value" parameter, or
- something more isoteric ?
-
- I guess F90 pointers can be passed as long as the F90 type it points
- to has a compatible C/C++ struct defined in the C/C++ code ? Only in
- that case, dereferencing the pointer would be meaningful.
- Or perhaps this is not so easy ?
-
- It would be interesting to hear if someone have successfully done
- these things, as I might need to do some F90 stuff one day.
-
-
- Carsten Arnholm
- ca@sesam.dnv.no
-
-